package com.eternal.base.concat;

import androidx.room.ColumnInfo;
import androidx.room.TypeConverters;

import com.eternal.base.data.source.BooleanConverters;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Locale;

public class TmpHum implements Cloneable{
    static SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd hh:mm", Locale.ENGLISH);

    public long time;
    public int tmp;
    public char hum;
    public boolean off;
    @TypeConverters(BooleanConverters.class)
    public List<Boolean> portStateList;

    private int castInt(String time){
        try {
            return ((int) (format.parse(time).getTime() / 1000));
        } catch (ParseException e) {
            return 0;
        }
    }

    public TmpHum clone(){
        try {
            TmpHum clone = (TmpHum) super.clone();
            clone.time=time;
            clone.tmp=tmp;
            clone.hum = hum;
            clone.off = off;
            clone.portStateList = portStateList;
            return clone;
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
//            return new TmpHum(time, tmp, hum);
            return null;
        }
    }

    public int getTmpValue() {
        return tmp;
    }
}
